<?php
session_save_path("/home/users/web/b2423/ipg.projectffcom/cgi-bin/tmp"); 
session_start();
//validateForm();

$con = mysql_connect("projectffcom.ipagemysql.com", "admin_user", "poghjk123"); 
mysql_select_db(main, $con);

$email = $_POST[email];
$firstname = $_POST['firstname'];
$username = $_POST['username'];
$lastname = $_POST['lastname'];
$password = $_POST['password'];
$full_name = $firstname." ".$lastname;

$query = "INSERT INTO USER_INFO VALUES('$username', '$firstname','$lastname', '$full_name', MD5('$password'), '$email', DEFAULT)";

if(!mysql_query($query))
{
die('Error ' . mysql_error());
}

else{
	$_SESSION['username'] = $username;
	header('Location: http://www.project-ff.com/trunk/main/edit_profile.php'); 
}

mysql_close($con);


function forward($url){
	?>
    <!DOCTYPE html>
	<html>
	<head>
    	</head>
	<body>
	
	Error...
	
	<script>
	window.location='<?php echo $url; ?>';
	return true;
	</script>

     </body>
     </html>
	<?php
	exit;
}

function validateForm(){
	
$firstnameLength = strlen($_POST['firstname']);
$lastnameLength = strlen($_POST['lastname']);
$usernameLength = strlen($_POST['username']);
$passwordLength = strlen($_POST['password']);
$betapassLength = strlen($_POST['betapass']);
	$boolean = false;

	if(($firstnameLength == 0) || ($firstnameLength) > 20){
		forward("/register/error.html");
	}

	else if(($lastnameLength == 0) || ($lastnameLength) > 20){
		forward("/register/error.html");
	}

	else if(($usernameLength == 0) || ($usernameLength) > 20){
		forward("/register/error.html");
	}

else if(($passwordLength == 0) || ($passwordLength) > 20){
	forward("/register/error.html");
	}	

	else if(($betapassLength == 0) || ($betapassLength) > 20){
		forward("/register/error.html");
	}	
	exit;
}


?>
